package cn.jbt.api.admin.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.jbt.api.admin.entity.SysLoginLog;
import cn.jbt.api.admin.service.ISysLoginLogService;
import cn.jbt.common.PageQryParam;
import cn.jbt.common.PageQryResult;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/system/loginLog")
@Slf4j
@AllArgsConstructor
public class SysLoginLogController {

    private final ISysLoginLogService iSysLoginLogService;

    @PostMapping("/list")
    @SaCheckPermission("system:loginLog:list")
    public PageQryResult<SysLoginLog> getAllByPage(@Valid @RequestBody PageQryParam<SysLoginLog> pageQryParam) {
        return iSysLoginLogService.getAllByPage(pageQryParam);
    }

    @PostMapping("/del")
    @SaCheckPermission("system:loginLog:del")
    public void del(@NotEmpty @RequestBody List<Long> ids) {
        iSysLoginLogService.del(ids);
    }

    @PostMapping("/delAll")
    @SaCheckPermission("system:loginLog:delAll")
    public void delAll() {
        iSysLoginLogService.delAll();
    }

}
